package com.basic.hellorabbit.controller;

import com.basic.hellorabbit.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.File;

/**
* @Description:    邮件
* @Author:         Joe
* @CreateDate:     2020/3/20 23:43
*/
@Controller
public class EmailController {

    @Autowired
    private EmailService emailService;

    @ResponseBody
    @RequestMapping(value = "/stringEmaile",method = RequestMethod.GET)
    public String sendStringEmail(){
        emailService.sendStringEmail("707714103@qq.com","你好","我发的你收到了吗？");
        return "发送成功";
    }

    @ResponseBody
    @RequestMapping(value = "/bigEmaile",method = RequestMethod.GET)
    public String sendBigEmail(){
        File file = new File("src/main/resources/static/zong.jpg");
        emailService.sendBigEmail("707714103@qq.com","你好，美图请查收","看我拍的咋样？",file);
        return "发送成功";
    }

    @ResponseBody
    @RequestMapping(value = "/templateEmail",method = RequestMethod.GET)
    public String sendTemplateEmail(){
        //emailService.sendTemplateEmail("707714103@qq.com","激活邮件","freemarkerTemplate.html");
        emailService.sendTemplateEmail("707714103@qq.com","激活邮件","thymeleafTemplate.html");
        return "发送成功";
    }

}
